<template>
	<!--代理端小区订单-->
	<view class="community">
		<view class="head_bg">
			<view class="cu-bar search">
				<view class="search-form bg-white" style="border-radius:50rpx;">
					<text class="cuIcon-search"></text>
					<input type="text" placeholder="" confirm-type="search" @input="getsjhm"></input>
					 <view @tap="search" class="text-right margin-right-sm text-lg">搜索</view>
				</view>
			</view>
		</view>
		<view class="big_box" style="margin-top: -50rpx;">
			<view v-if="list.length>0" v-for="(info,index) in list" :key="index">
				<view class="equ_list" style="padding-top: 20rpx;">
					<view class="ele_title" >
						<view class="ele_title_left">
							<view class="ele_title_inner">{{info.residential_quarters_name}}</view>
						</view>
						<view class="falt_status">分成模式：
						<text v-if="info.sharing_mode==1">毛利</text>
						<text v-if="info.sharing_mode==2">纯利</text>
						</view>
					</view>
					<view class="equ_list_inner">
						<view class="equ_list_inner_text">充电账号：{{info.phone_number}}</view>
						<view class="equ_list_inner_text">充电时长：{{info.charging_minutes}}</view>
						<view class="equ_list_inner_text">终端编号：{{info.equipment_number}}
							<text class="padding-left-xs" v-if="info.socket_port==0">左</text>
							<text class="padding-left-xs" v-else>右</text>
						</view>
						<view class="equ_list_inner_text">起止时间：{{info.begin_time}} 至 {{info.end_time}}</view>
					</view>
					<view class="community_address">
						<view class="community_address_left">
							<image class="community_address_iconl" src="../../../common/img/dizhi_hui.png" mode=""></image>
							<view class="community_address_text">{{info.residential_quarters_address}}</view>
						</view>
						<view class="basis-xs text-center" @tap="showyyinfo(index)">
							<text :class="'cuIcon-' + info.iconname"></text>
						</view>
					</view>
				</view>	
				<view class="big_inner_two" v-if="info.isshow">
					<view class="operating_box" style="box-shadow: none;background: #F6FBFF;">
						<view class="flex padding-top-xs padding-left-lg">
							<view class="flex-sub">分成比例：{{info.sharing_ratio}}</view>
							<view class="flex-sub">分成金额：{{info.sharing_money}}</view>
						</view>
						<view class="flex padding-top-xs padding-left-lg">
							<view class="flex-sub">消费电量：{{info.power_consumption}}</view>
							<view class="flex-sub">消费电费：{{info.electricity_fees}}</view>
						</view>
					</view>
				</view>	
			</view>
			<view style="height:100rpx;"></view>
			<view v-if="list.length==0" class="margin-top-lg text-center">
				<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
			</view>
			<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
				{{loadingTxt}} 共({{list.length}}条记录)
			</view>
		</view>
		
	</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				guid:'',
				list:{},
				loadingTxt:'加载更多',
				totle:1,
				phone_number:'',
				info:{
				residential_quarters_name:'',//	字符串	小区名称
				residential_quarters_address:'',//	字符串	小区地址
				consumption_amount:'',//	字符串	结算金额
				socket_port:'',//	字符串	端口 0左 1右
				equipment_number:'',//	字符串	设备编号
				charging_minutes:'',//	字符串	充电时长
				begin_time:'',//	字符串	开始时间
				end_time:'',//	字符串	结束时间
				sharing_mode:'',//	字符串	分成模式  1毛利 2纯利
				sharing_ratio:'',//	字符串	分成比例
				sharing_money:0.00,//	浮点型	分成金额
				task_state:'',//	字符串	任务状态 2已完成（固定返回只有状态等于2的）
				consumption_pattern:0,//	整型	消费模式 0 余额 1刷卡 2套餐
				power_consumption:0.00,//	浮点型	消耗电量
				electricity_fees:0.00//	浮点型	订单电费
              }
			}
		},
		onLoad(options) {
			this.guid=options.guid;
		},
		onShow() {
			page=1;
			this.getList();
		},
		methods: {
			getsjhm: function(event) {
				this.phone_number = event.target.value  
			}, 
			search(){
				this.getList();
				this.phone_number=''
			},
			getList(){
				let that=this;
				that.http.tokenreq({
					url: 'agent/v1/order',
					data:{
						'phone_number':that.phone_number,
						'pageindex':page
					}
				}).then((res) => {
					let e=res.data;
					console.log(e)
					if(e.code==0 && e.success){
						let list=e.rows;
						list.forEach(item => {
							item.isshow = false;
							item.iconname="right"
						});
						that.list=list;
						page++;
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				that.http.tokenreq({
					url: 'agent/v1/order',
					data:{'phone_number':that.phone_number,
						'pageindex':page
					}
				}).then((res) => {
					uni.hideLoading();
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.rows);
						page++
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			//商品详情显示或隐藏
			showyyinfo(index){
				let info=this.list[index];
				if(info.iconname=="right"){
					info.iconname="unfold"
				}else{
					info.iconname="right"
				}
				info.isshow=!info.isshow;
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
				// this.getMoreNews()
			}
		}
	}
</script>